package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Propaganda;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.PropagandaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/27 12:36
 */
@Api(tags = "推广信息 安卓专用")
@CrossOrigin
@RestController
@RequestMapping("/propaganda")
public class PropagandaController {

    @Autowired
    private PropagandaService propagandaService;

    @ApiOperation("添加推广信息 除了id日期都是必须的")
    @PostMapping("/add")
    public R<Void> add(Propaganda propaganda) {
        return propagandaService.add(propaganda);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return propagandaService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(Propaganda propaganda) {
        return propagandaService.update(propaganda);
    }

    @ApiOperation("page")
    @GetMapping("/page")
    public R<IPage<Propaganda>> page(@RequestParam(defaultValue = "1") Integer page,
                                     @RequestParam(defaultValue = "10") Integer size) {
        return propagandaService.page(page, size);
    }

    @ApiOperation("获取所有推广信息进行显示")
    @GetMapping("/getAll")
    public R<List<Propaganda>> getAll(){
        return propagandaService.getAll();
    }

}
